﻿//Show grid..
Ext.onReady(function () {
    //Infrastructure.InfraHospUser.showInfraHospUserGrid();
    var userGrid = new Infrastructure.InfraHospUser.GridPanel();

    // 菜单grid
    var m_InfraMenuGridPanel = new Infrastructure.Menu.GridPanel();
   
    var MenuStore = m_InfraMenuGridPanel.getStore();
    var MenuRootReocdData = {
        "Name": "所有菜单",
        "Code": "",
        "Id": "0",
        "ParentId": null,
        "Leaf": null,
        "Level": 0,
        "IsExtPage": null
    };
    MenuStore.isLoadedNode = function (rc) {
        return true;
    }
    var menuRootReocd = new MenuStore.recordType(MenuRootReocdData, 0);
   

    // 增加表格选择事件处理
    var userGridSelModel = userGrid.selModel;
    userGridSelModel.on({
        'rowselect': function (sm, rowIndex, r) {
            var id = sm.getSelected().get("Id");
            m_InfraMenuGridPanel.onLoadUserMenu(id);
        },
        'rowdeselect': function (sm, rowIndex, r) {
            m_InfraMenuGridPanel.onUnLoadUserMenu();
        }
    });

    // 权限管理Tab页
    var UserInfoTab = new Ext.TabPanel({
        id: "Infra_User_InfoTab",
        frame: true,
        border: true,
        autoScroll: true,
        enableTabScroll: true,
        activeTab: 0,
        items: [new Ext.Panel({
            id: 'Infra_User_InfoTab_MenuPermissionPanel',
            title: '菜单权限',
            autoScroll: true,
            layout: 'fit',
            border: false,
            items: [m_InfraMenuGridPanel]
        })]
    });

    // 创建框架
    userGrid.region = "center";
    UserInfoTab.region = "east";
    UserInfoTab.width = 250;
    var main = new Ext.Panel({
        border: false,
        layout: 'border',
        items: [userGrid, UserInfoTab]
    });

    //加载
    JsHelper.ExtTabDoLayout(main);
    userGrid.store.load({
        params: {
            start: 0,
            limit: ALL_PAGESIZE_SETTING
        }
    });

    
    //MenuStore.removeAll();
    //MenuStore.insert(0, menuRootReocd);
    
    //读取菜单
    //MenuStore.load({
    //    add: true
    //});
});
